package edu.whu.rose.clock.kps.algorithm.banks2;

import edu.whu.rose.clock.kps.graph.GraphVertex;
import edu.whu.rose.clock.ssql.util.SequentialIntArray;

public class ActivationVertex extends GraphVertex implements Comparable<ActivationVertex> {

	private SequentialIntArray p;
	private int[] predecessors;
	private double[] distances;
	private double[] activations;
	private double totalActivation;
	private int depth;
	
	private int indexID;
	private boolean in;
	private boolean out;
	private boolean inX;
	private boolean outX;
	
	public ActivationVertex(int id, int groupNum) {
		super(id);
		p = new SequentialIntArray();
		predecessors = new int[groupNum];
		distances = new double[groupNum];
		for (int i = 0; i < groupNum; i++) {
			distances[i] = Double.MAX_VALUE;
		}
		activations = new double[groupNum];
		in = false;
		out = false;
		inX = false;
		outX = false;
	}
	
	public int compareTo(ActivationVertex x) {
		if (totalActivation > x.getTotalActivation()) {
			return 1;
		}
		else if (totalActivation < x.getTotalActivation()) {
			return -1;
		}
		else {
			return 0;
		}
	}
	
	public int hashCode() {
		return (new Integer(id)).hashCode();
	}

	public int getIndexID() {
		return indexID;
	}

	public void setIndexID(int indexID) {
		this.indexID = indexID;
	}

	public double getTotalActivation() {
		return totalActivation;
	}

	public void setTotalActivation(double totalActivation) {
		this.totalActivation = totalActivation;
	}

	public double getActivation(int group) {
		return activations[group];
	}

	public void setActivation(int group, double activation) {
		totalActivation -= activations[group];
		activations[group] = activation;
		totalActivation += activation;
	}

	public int getDepth() {
		return depth;
	}

	public void setDepth(int depth) {
		this.depth = depth;
	}

	public double getDistances(int group) {
		return distances[group];
	}

	public void setDistances(int group, double distance) {
		distances[group] = distance;
	}

	public int[] getPredecessors() {
		return predecessors;
	}

	public void setPredecessors(int group, int predecessor) {
		predecessors[group] = predecessor;
	}

	public boolean isIn() {
		return in;
	}

	public void setIn(boolean in) {
		this.in = in;
	}

	public boolean isOut() {
		return out;
	}

	public void setOut(boolean out) {
		this.out = out;
	}

	public boolean isInX() {
		return inX;
	}

	public void setInX(boolean inX) {
		this.inX = inX;
	}

	public boolean isOutX() {
		return outX;
	}

	public void setOutX(boolean outX) {
		this.outX = outX;
	}
}
